package 异常处理;

import java.util.Scanner;

class ScoreException extends Exception{

    private String message;

    public ScoreException() {
        message = "您输入的成绩异常，请核实！";
    }

    public String show(){
        return message;
    }
}

class Student{
    private double score;

    public void setScore(double score) throws ScoreException{
        this.score = score;

        if(score > 100 || score < 0){
            throw new ScoreException();
        }
    }

    public double getScore() {
        return score;
    }
}
public class 学生成绩 {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        try{
            double score = reader.nextDouble();
            Student zhangsan = new Student();
            zhangsan.setScore(score);
            System.out.println("成绩为"+zhangsan.getScore());
        }catch (ScoreException e){
            System.out.println(e.show());
        }finally {
            System.out.println("程序结束");
        }

    }
}
